import { createAxios } from '@/utils/http/axios';
import { IotUniDataLog } from '@/api/hc/iotDeviceData';

// const hcApi = import.meta.env.VITE_HC_API;

// export interface IotRawMsgWrapper {
//   iotProtocol: string;
//   topic: string;
//   ts?: number;
//   headers?: Map<string, string>;
//   contentType?: string;
//   rawStr: string;
//   serverKey: string;
// }

enum Api {
  encode = '/tbuser/iot/coder/encode',
  decode = '/tbuser/iot/coder/decode',
}

export function decodeApi(iotUniDataLog: IotUniDataLog) {
  return createAxios({
    requestOptions: {
      apiUrl: '/hc-api',
      // withToken: false,
    },
  }).post({
    url: Api.decode,
    data: iotUniDataLog,
  });
}

export function encodeApi(req: any) {
  return createAxios({
    requestOptions: {
      apiUrl: '/hc-api',
      // withToken: false,
    },
  }).post({
    url: Api.encode,
    data: req,
  });
}
